package com.insurance.service.impl;

import com.insurance.service.PartnerInfoRoleService;
import com.insurance.service.PartnerRolePermissionService;
import com.insurance.service.PartnerService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Style
 * @version 1.0
 * @date 2021/2/27
 **/
@Service
public class PartnerServiceImpl implements PartnerService {

    @Autowired
    private PartnerInfoRoleService partnerInfoRoleService;

    @Autowired
    private PartnerRolePermissionService partnerRolePermissionService;

    @Override
    public List<String> getPermissionListByPartnerId(String partnerId) {
        if(StringUtils.isBlank(partnerId)){
            return new ArrayList<String>();
        }
        //通过合作方主键获取角色集合
        List<String> roleList = partnerInfoRoleService.getRoleStrListByPartnerId(partnerId);
        //通过合作集合获取权限集合
        List<String> permissionList = partnerRolePermissionService.getRolePermissionStrByRoleIdList(roleList);
        return permissionList;
    }

}
